/*
 * Copyright (c) 2020, 2023, 3044483124@qq.com All rights reserved.
 *
 */

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * <p>Project: jdbc - JDBC
 * <p>Powered by jiangbo On 2023-02-13
 * 14:41:55
 * <p>Created by IntelliJ IDEA
 *
 * @author jiangbo [3044483124@qq.com]
 * @version 1.0
 * @since 8/17
 */
public class JDBC {
    public static void main(String[] args) throws Exception {
        //mysql8.0-name:root-pwd:root
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3307/test", "root", "root");
        Statement st = conn.createStatement();
        //String sql ="insert into t1 value(5,'小军')";
        String sql ="select * from t1";
        ResultSet rs = st.executeQuery(sql);
        while(rs.next()){
            System.out.println(rs.getInt("id")+" "+rs.getString("name"));
        }
        System.out.println(rs);
        conn.close();
        st.close();
    }
}


